<?php
//登入中间件
namespace app\api\middleware;

//TPCache缓存模块
use think\facade\Cache;

//公共类
use app\api\common\Common;

class Identity
{
    public function handle($request, \Closure $next)
    {
        //整理数据
        $data = $request->param();

        if(empty($data['UUID'])){
            return Common::create([],'没有登入',400);
        }else{
            $uuid = $data['UUID'];
            $cache = Cache::get($uuid);
            //判断缓存是否存在
            if(empty($cache)){
                return Common::create([],'UUID已失效',400);
            }
        }
        
        return $next($request);
    }
}